<template>
    <div style="text-align: center">
        <el-tree
            :data="menuTree"
            show-checkbox
            node-key="id"
            ref="tree"
            default-expand-all
            :default-checked-keys="activeMenuTree"
            :props="defaultProps">
            <span class="custom-tree-node" slot-scope="{ node, data }">
                <div><span style="margin-right: 2px;font-size: 16px" :class="`iconfont ${data.icon}`"></span>{{ data.name }}</div>
            </span>
        </el-tree>
        <el-button style="margin-top: 10px" type="primary" @click="save">提交</el-button>
    </div>
</template>

<script>
    export default {
        name: "RoleAssignment",
        data() {
            return {
                defaultProps: {
                    children: 'children',
                    label: 'name'
                },
            }
        },
        props:['menuTree',"activeMenuTree"],
        methods:{
            save(){
                //半选中的父级key
                let HalfCheckedKeys =  this.$refs.tree.getHalfCheckedKeys();
                //全选中的key
                let checkKeys = this.$refs.tree.getCheckedKeys();
                let combinedArray = HalfCheckedKeys.concat(checkKeys);
                this.$emit("roleMenuSubmit",combinedArray)
            },
        }
    }
</script>

<style scoped lang="less">

</style>